package com.ruoyi.biz.letter.service.impl;

import java.util.List;

import com.ruoyi.biz.letter.util.AcceptDeptUtil;
import com.ruoyi.biz.letter.util.CategoryUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.biz.letter.mapper.BizMessageBoardMapper;
import com.ruoyi.biz.letter.domain.BizMessageBoard;
import com.ruoyi.biz.letter.service.IBizMessageBoardService;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 人民网留言板Service业务层处理
 *
 * @author Fei.Cong
 * @date 2024-07-18
 */
@Service
public class BizMessageBoardServiceImpl extends ServiceImpl<BizMessageBoardMapper, BizMessageBoard> implements IBizMessageBoardService {

    @Autowired
    private BizMessageBoardMapper bizMessageBoardMapper;

    /**
     * 分页查询人民网留言板
     *
     * @param page
     * @param bizMessageBoard 人民网留言板
     */
    @Override
    public IPage<BizMessageBoard> pageList(BizMessageBoard bizMessageBoard, IPage<BizMessageBoard> page) {
        IPage<BizMessageBoard> resultPage = bizMessageBoardMapper.selectPageList(page, bizMessageBoard);
        for (BizMessageBoard record : resultPage.getRecords()) {
            record.setFirstCategoryName(CategoryUtil.getCacheCategory(record.getPCategoryId()));
            record.setSecondCategoryName(CategoryUtil.getCacheCategory(record.getSCategoryId()));
            AcceptDeptUtil.parseAcceptDept(record);
        }
        return resultPage;
    }

    /**
     * 条件查询人民网留言板
     *
     * @param bizMessageBoard 人民网留言板
     * @return
     */
    @Override
    public List<BizMessageBoard> queryList(BizMessageBoard bizMessageBoard) {
        LambdaQueryWrapper<BizMessageBoard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        return bizMessageBoardMapper.selectList(lambdaQueryWrapper);
    }

}
